package cn.szsys.integration.constants;

/**
 * tianqushuzi二要素映射码
 *
 * @author Ryan
 * @since 2025-05-07
 **/
public enum TqszTwoElementMapperedEnum implements UpAndDownCodeBilled {
    /**
     * 上游
     * 200	一致	计费
     * 10004009	不一致	计费
     * 10004010	姓名或身份证号错误	不计费
     * 7001	数据源异常，请稍后重试	不计费
     * <p>
     * <p>
     * 下游
     * 01-认证⼀致
     * 02-认证不⼀致
     * 03-认证不确定
     * 04-认证失败
     */
    IDENTICAL("200", "01", true),
    INCONSISTENT("10004009", "02", true),
    INFORMATION_ERROR("10004010", "03", false),
    DATA_SOURCE_ERROR("7001", "04", false);
    private final String upstreamCode;
    private final String downstreamCode;
    private final Boolean billing;

    TqszTwoElementMapperedEnum(String upstreamCode, String downstreamCode, Boolean billing) {
        this.upstreamCode = upstreamCode;
        this.downstreamCode = downstreamCode;
        this.billing = billing;
    }

    public static TqszTwoElementMapperedEnum getByUpstreamCode(String upstreamCode) {
        for (TqszTwoElementMapperedEnum resultEnum : TqszTwoElementMapperedEnum.values()) {
            if (resultEnum.upstreamCode.equals(upstreamCode)) {
                return resultEnum;
            }
        }
        return DATA_SOURCE_ERROR;
    }


    /**
     * 上游code
     */
    @Override
    public String getUpstreamCode() {
        return this.upstreamCode;
    }

    /**
     * 下游code
     */
    @Override
    public String getDownstreamCode() {
        return this.downstreamCode;
    }

    /**
     * 是否计费
     */
    @Override
    public Boolean getBilling() {
        return this.billing;
    }
}
